package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.POST;
import java.util.Map;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/7 17:55
 */

@RequestMapping("/baidu")
@RestController
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     * 更新地理位置
     * @param map
     * @return
     */
    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody Map map){

        // 经度
        Double longitude = Double.valueOf(map.get("longitude").toString());
        // 纬度
        Double latitude = Double.valueOf(map.get("latitude").toString());
        String addrStr = map.get("addrStr").toString();
        baiduService.location(longitude, latitude, addrStr);
        return ResponseEntity.ok(null);
    }
}
